import * as constant from '../common/constant';

let orderType = id => {
  let temp = constant.ORDER_TYPE_LIST.filter(item => item.id === id);
  if (temp.length > 0) {
    return temp[0].value;
  }
  return '';
};

let orderListType = value => {
  let listTypeName = '';
  switch (value) {
    case '1':
      listTypeName = '待办工单';
      break;
    case '2':
      listTypeName = '已参与的工单';
      break;
    case '3':
      listTypeName = '已结束的工单';
      break;
    case '4':
      listTypeName = '草稿箱';
      break;
    case '5':
      listTypeName = '所有工单';
      break;
  }
  return listTypeName;
};

let workOrderStatus = value => {
  let workOrderStatusName = '';
  switch (value) {
    case 1:
      workOrderStatusName = '创建';
      break;
    case 2:
      workOrderStatusName = '草稿存档';
      break;
    case 3:
      workOrderStatusName = '处理中';
      break;
    case 4:
      workOrderStatusName = '挂起';
      break;
    case 5:
      workOrderStatusName = '已处理';
      break;
    case 6:
      workOrderStatusName = '结束';
      break;
  }
  return workOrderStatusName;
};

let subStatus = value => {
  let subStatusName = '';
  switch (value) {
    case 1:
      subStatusName = '挂起';
      break;
    case 2:
      subStatusName = '驳回';
      break;
    case 3:
      subStatusName = '待接单';
      break;
  }
  return subStatusName;
};

let orderLevel = value => {
  let orderLevelName = '-';
  switch (value) {
    case 1:
      orderLevelName = '极低';
      break;
    case 2:
      orderLevelName = '低';
      break;
    case 3:
      orderLevelName = '中';
      break;
    case 4:
      orderLevelName = '高';
      break;
    case 5:
      orderLevelName = '极高';
      break;
  }
  return orderLevelName;
};

let dataCenterStatus = value => {
  let dataCenterStatusName = '';
  switch (value) {
    case 'innstruction':
      dataCenterStatusName = '建设中';
      break;
    case 'inuse':
      dataCenterStatusName = '使用中';
      break;
    case 'outage':
      dataCenterStatusName = '停用';
      break;
    case 'evaluating':
      dataCenterStatusName = '评估中';
      break;
    case 'maintenance':
      dataCenterStatusName = '维修中';
      break;
    case 'unuse':
      dataCenterStatusName = '未使用';
      break;
  }
  return dataCenterStatusName;
};

let orgType = value => {
  let orgTypeName = '';
  switch (value) {
    case 'selfsupport':
      orgTypeName = '自营';
      break;
    case 'combinedbuild':
      orgTypeName = '合建';
      break;
    case 'threeparty':
      orgTypeName = '第三方';
      break;
    case 'operator':
      orgTypeName = '运营商';
      break;
  }
  return orgTypeName;
};

let orgTypes = value => {
  let typeArray = value && value.split(',');
  typeArray = typeArray.map(type => {
    return orgType(type);
  });
  return typeArray && typeArray.join(',');
};

let isSecurity = value => (value === 'true' ? '是' : '否');

export {
  orderType,
  orderListType,
  workOrderStatus,
  subStatus,
  orderLevel,
  dataCenterStatus,
  orgType,
  orgTypes,
  isSecurity
};
